<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/plateform/include/common-base.jsp"%>
  <title>校验规则选择</title>
  <style>
.validbox{border-left:1px solid #f39c12;border-right:1px solid #f39c12;border-bottom:1px solid #f39c12;}
  </style>
  
</head>
<body>
	<div class="content">
		<div id="form-validator-set-box">
			<div class="panel">
				<div class="panel-body">
					<div class="col-sm-12" id="form-validator-body">
					</div>
				</div>
			</div>
		</div>
	</div> 
<script>
$(function (){
    initFormValidatorData();
});
function initFormValidatorData() {
    var rowsColum=new Array();
    rowsColum[0]= eval({"title":"手机号","regexp":"^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\\d{8})$","tips":"请输入正确的手机号码！"});
    rowsColum[1]= eval({"title":"座机号","regexp":"^(\\d{3,4}-)?\\d{6,8}(-\\d{3,5})?$","tips":"请输入正确的座机号码！"});
    rowsColum[2]= eval({"title":"传真号","regexp":"^(\\d{8}|\\d{7})$","tips":"请输入正确的传真号！"});
    rowsColum[3]= eval({"title":"邮箱","regexp":"^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,3}){1,2})$","tips":"请输入正确的邮箱！"});
    rowsColum[4]= eval({"title":"邮政编码","regexp":"^[a-zA-Z0-9 ]{3,12}$","tips":"请输入正确的邮政编码！"});
    rowsColum[5]= eval({"title":"IP地址","regexp":"^[0-9.]{1,20}$","tips":"请输入正确的IP地址！"});
    rowsColum[6]= eval({"title":"字母、数字、下划线","regexp":"^\\w+$","tips":"必须由字母、数字或下划线组成！"});
    rowsColum[7]= eval({"title":"大写英文字母","regexp":"^[A-Z]+$","tips":"大写英文字母！"});
    rowsColum[8]= eval({"title":"小写英文字母","regexp":"^[a-z]+$","tips":"小写英文字母！"});
    rowsColum[9]= eval({"title":"小写英文、数字","regexp":"^[a-z0-9]+$","tips":"请输入正确的小写英文、数字！"});
    rowsColum[10]= eval({"title":"小写字母、数字、下划线组成","regexp":"^[a-z0-9_]*$","tips":"必须由小写字母、数字、下划线组成！"});
    rowsColum[11]= eval({"title":"小写字母、数字、下划线组成，且只能以字母开头","regexp":"^[a-z][a-z0-9_]*$","tips":"必须由小写字母、数字、下划线组成，且只能以字母开头！"});
    rowsColum[12]= eval({"title":"小写字母、数字、下划线、横线组成，且只能以字母开头","regexp":"^[a-z][a-z0-9_-]*$","tips":"必须由小写字母、数字、下划线、横线组成，且只能以字母开头！"});

    var myData = {};
    myData.rows=rowsColum;
    var data = baidu.template("form-validator-template",eval(myData));
    $("#form-validator-body").html(data);
}
//勾选对象
function getChecked(obj){
    var regexpObj = $(obj).parent().parent().parent().find("input[name='input-regexp']");
    var tipsObj = $(obj).parent().parent().parent().find("input[name='input-tips']");
    var titleObj = $(obj).parent().parent().parent().find(".label-title");
    var regexpVal = regexpObj.val();
    var tipsVal = tipsObj.val();
    if(strUtil.isNull(tipsObj.val())){
        layer.alert(titleObj.text()+"的提示信息不能为空！");
        return;
	}
    var dataJson = eval({"regexp":regexpVal,"tips":tipsVal});
    console.log(dataJson);
    parent.preCheckValidator(dataJson);

}
</script>

<script type="text/template" id="form-validator-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<div class="col-sm-12">
			<div class="box box-warning validbox">
				<div class="box-header bg-warning">
					<label class="control-label label-title"><?=rows[i].title?></label>
					<div class="box-tools pull-right">
						<input name="input-regexp" value="<?=rows[i].regexp?>" type="radio" onclick="getChecked(this)"> 选用
					</div>
				</div>
				<div class="box-body">
					<div class="form-group">
						<span class="help-block"><?=rows[i].regexp?></span>
						<input name="input-tips" class="form-control" placeholder="请输入提示信息" value="<?=rows[i].tips?>" type="text"/>
					</div>
				</div>
			</div>
		</div>
	<?}?>
</script>


